]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Use new clutter_actor_get_resource_scale() API
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 28 May 2020 12:39:11 +0000 (14:39 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 30 Jun 2020 13:42:18 +0000 (13:42 +0000)
Update the existing users of clutter_actor_get_resource_scale() to the
new API which doesn't return a boolean value.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1287

src/shell-screenshot.c
src/st/st-drawing-area.c
src/st/st-icon.c
src/st/st-label.c
src/st/st-private.c
src/st/st-widget.c

index e60d5891b11bd62f226f35b2ad0d5a7313f9bb21..36ca2fb24b131d819ed7b94501778762bcb6df58 100644 (file)
@@ -393,8 +393,7 @@ grab_window_screenshot (ClutterActor *stage,
       if (meta_window_get_client_type (window) == META_WINDOW_CLIENT_TYPE_WAYLAND)
         {
           float resource_scale;
-          if (!clutter_actor_get_resource_scale (window_actor, &resource_scale))
-            resource_scale = 1.0f;
+          resource_scale = clutter_actor_get_resource_scale (window_actor);
 
           cairo_surface_set_device_scale (priv->image, resource_scale, resource_scale);
         }
index a9daca562d410aafb8b4853a3aaae2f1b7ca8f59..44d7c0add9d165fabba13c15ce18a34e1f75f127 100644 (file)
@@ -85,12 +85,7 @@ st_drawing_area_allocate (ClutterActor          *self,
   int width, height;
   float resource_scale;
 
-  if (!st_widget_get_resource_scale (ST_WIDGET (self), &resource_scale))
-    {
-      ClutterActorBox empty = CLUTTER_ACTOR_BOX_INIT_ZERO;
-      clutter_actor_set_allocation (self, &empty);
-      return;
-    }
+  resource_scale = clutter_actor_get_resource_scale (self);
 
   clutter_actor_set_allocation (self, box);
   st_theme_node_get_content_box (theme_node, box, &content_box);
@@ -116,8 +111,8 @@ st_drawing_area_resource_scale_changed (StWidget *self)
   float resource_scale;
   ClutterContent *content = clutter_actor_get_content (CLUTTER_ACTOR (self));
 
-  if (st_widget_get_resource_scale (ST_WIDGET (self), &resource_scale))
-    clutter_canvas_set_scale_factor (CLUTTER_CANVAS (content), resource_scale);
+  resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (self));
+  clutter_canvas_set_scale_factor (CLUTTER_CANVAS (content), resource_scale);
 }
 
 static void
@@ -215,15 +210,10 @@ st_drawing_area_get_surface_size (StDrawingArea *area,
   content = clutter_actor_get_content (CLUTTER_ACTOR (area));
   clutter_content_get_preferred_size (content, &w, &h);
 
-  if (st_widget_get_resource_scale (ST_WIDGET (area), &resource_scale))
-    {
-      w /= resource_scale;
-      h /= resource_scale;
-    }
-  else
-    {
-      w = h = 0.0f;
-    }
+  resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (area));
+
+  w /= resource_scale;
+  h /= resource_scale;
 
   if (width)
     *width = ceilf (w);
index 38d58205d5817c1e9f3bce28a56b36bcfc4ef165..3657ccc2c83ddcb0cd5b19fe065d40437da867e8 100644 (file)
@@ -425,8 +425,7 @@ st_icon_update (StIcon *icon)
       return;
     }
 
-  if (!st_widget_get_resource_scale (ST_WIDGET (icon), &resource_scale))
-    return;
+  resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (icon));
 
   theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
   if (theme_node == NULL)
index 7415dec29ceff071b656ec3303073d81928e0cbe..4d8271d694828775cab9c53c73a0e22018d49f8b 100644 (file)
@@ -201,44 +201,42 @@ st_label_paint (ClutterActor        *actor,
 
   if (shadow_spec)
     {
+      ClutterActorBox allocation;
+      float width, height;
       float resource_scale;
 
-      if (clutter_actor_get_resource_scale (priv->label, &resource_scale))
+      clutter_actor_get_allocation_box (priv->label, &allocation);
+      clutter_actor_box_get_size (&allocation, &width, &height);
+
+      resource_scale = clutter_actor_get_resource_scale (priv->label);
+
+      width *= resource_scale;
+      height *= resource_scale;
+
+      if (priv->text_shadow_pipeline == NULL ||
+          width != priv->shadow_width ||
+          height != priv->shadow_height)
+        {
+          g_clear_pointer (&priv->text_shadow_pipeline, cogl_object_unref);
+
+          priv->shadow_width = width;
+          priv->shadow_height = height;
+          priv->text_shadow_pipeline =
+            _st_create_shadow_pipeline_from_actor (shadow_spec,
+                                                   priv->label);
+        }
+
+      if (priv->text_shadow_pipeline != NULL)
         {
-          ClutterActorBox allocation;
-          float width, height;
-
-          clutter_actor_get_allocation_box (priv->label, &allocation);
-          clutter_actor_box_get_size (&allocation, &width, &height);
-
-          width *= resource_scale;
-          height *= resource_scale;
-
-          if (priv->text_shadow_pipeline == NULL ||
-              width != priv->shadow_width ||
-              height != priv->shadow_height)
-            {
-              g_clear_pointer (&priv->text_shadow_pipeline, cogl_object_unref);
-
-              priv->shadow_width = width;
-              priv->shadow_height = height;
-              priv->text_shadow_pipeline =
-                _st_create_shadow_pipeline_from_actor (shadow_spec,
-                                                       priv->label);
-            }
-
-          if (priv->text_shadow_pipeline != NULL)
-            {
-              CoglFramebuffer *framebuffer;
-
-              framebuffer =
-                clutter_paint_context_get_framebuffer (paint_context);
-              _st_paint_shadow_with_opacity (shadow_spec,
-                                             framebuffer,
-                                             priv->text_shadow_pipeline,
-                                             &allocation,
-                                             clutter_actor_get_paint_opacity (priv->label));
-            }
+          CoglFramebuffer *framebuffer;
+
+          framebuffer =
+            clutter_paint_context_get_framebuffer (paint_context);
+          _st_paint_shadow_with_opacity (shadow_spec,
+                                         framebuffer,
+                                         priv->text_shadow_pipeline,
+                                         &allocation,
+                                         clutter_actor_get_paint_opacity (priv->label));
         }
     }
 
index 16a5e15dd6da3ce8c578467ee56f99ecfb40b9a8..a491c19535c0f3a7bb22457adb9d688068f8045a 100644 (file)
@@ -461,8 +461,7 @@ _st_create_shadow_pipeline_from_actor (StShadow     *shadow_spec,
   if (width == 0 || height == 0)
     return NULL;
 
-  if (!clutter_actor_get_resource_scale (actor, &resource_scale))
-    return NULL;
+  resource_scale = clutter_actor_get_resource_scale (actor);
 
   width = ceilf (width * resource_scale);
   height = ceilf (height * resource_scale);
index 9efffbd762f9214be9337dfa9e37cd75f70f5bf9..3d732a74a765e1cb70866984fa601e8428e5e562 100644 (file)
@@ -412,8 +412,7 @@ st_widget_paint_background (StWidget            *widget,
   float resource_scale;
   guint8 opacity;
 
-  if (!st_widget_get_resource_scale (widget, &resource_scale))
-    return;
+  resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (widget));
 
   framebuffer = clutter_paint_context_get_framebuffer (paint_context);
   theme_node = st_widget_get_theme_node (widget);
@@ -1413,8 +1412,10 @@ gboolean
 st_widget_get_resource_scale (StWidget *widget,
                               float    *resource_scale)
 {
-  return clutter_actor_get_resource_scale (CLUTTER_ACTOR (widget),
-                                           resource_scale);
+  if (resource_scale)
+    *resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (widget));
+
+  return TRUE;
 }
 
 static void